<?php
$params = array_merge(
    require BASE_PATH . '/common/config/params.php',
    require BASE_PATH . '/common/config/params-local.php',
    require __DIR__ . '/params.php',
    require __DIR__ . '/params-local.php'
);

$modules = require __DIR__ . '/modules.php';
return [
    'id' => 'app-internalapi',
    'basePath' => dirname(__DIR__),
    'controllerNamespace' => 'internalapi\controllers',
    'bootstrap' => ['log'],
    'modules' => $modules,
    'components' => [
        'request' => [
            'class' => 'heihei\rest\Request',
            'csrfParam' => '_csrf-internalapi',
            'parsers' => [
                'application/json' => 'yii\web\JsonParser',
                'text/json' => 'yii\web\JsonParser',
            ]
        ],
        'user' => [
            'identityClass' => 'internalapi\models\User',
            'enableSession' => false,
            'loginUrl' => null
        ],
        'securityJwt' => [
            'class' => 'heihei\security\Jwt',
            'key'=> '89794c5c8f80bed4916b4b8b6f9a024a'
        ],
        'session' => [
            // this is the name of the session cookie used for login on the internalapi
            'name' => 'hhf-internalapi',
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'authManager' => [
            'class' => 'heihei\rbac\AuthManager',
            'allowPermissions' => ['site/error','site/login']
        ],
        'errorHandler' => [
            'class' => 'heihei\rest\ErrorHandler'
        ],
        'urlManager' => [
            'enablePrettyUrl' => false,
            'showScriptName' => false,
            'rules' => [
                'login' => 'site/login',
                'logout' => 'site/logout'
            ],
        ]
    ],
    'params' => $params,
];
